<template>
    <div>
        <div class="chart-row" v-if="chatMessage.left">
            <span class="date">{{chatMessage.date}}</span>

            <div class="message">
                <img v-if="toUser.img" :src="toUser.img" class="user-portrait">
                <img v-else class="user-portrait" src="../../assets/default_img.jpg" alt="">

                <div class="user">
                    <span class="user-message">{{chatMessage.message}}</span>
                </div>
            </div>
        </div>
        <div class="chart-row" v-else>
            <span class="date">{{chatMessage.date}}</span>
            <div class="message" style="justify-content: flex-end;">
                <div class="user">
                    <span class="user-message">{{chatMessage.message}}</span>
                </div>
                <img v-if="userinfo.img" :src="userinfo.img" class="user-portrait">
                <img v-else class="user-portrait" src="../../assets/default_img.jpg" alt="">
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "chart-row",
        props: ["chatMessage", "userinfo","toUser"]

    }
</script>

<style lang="scss">
    .chart-row {
        display: flex;
        flex-direction: column;

        .message {
            display: flex;
            align-items: center;

            .user-portrait {
                width: 40px;
                height: 40px;
                border: 1px solid white;
                border-radius: 50%;
            }

            .user {
                width: 40%;
                padding: 10px 5px;
                background-color: rgba($color: #7a7a7a, $alpha: 0.7);
                border-radius: 5px;
                margin-left: 10px;
                display: flex;
                flex-direction: column;

                .user-message {
                    color: rgba($color: #000000, $alpha: .8);
                    font-size: 13px;
                    margin-bottom: 2px;
                }
            }
        }

        .date {
            color: rgba($color: #000000, $alpha: .6);
            font-size: 13px;
            text-align: center;
        }
    }
</style>
